/**
 * Created by Weizehua on 2017/1/22.
 */
import {tr} from "../Utils/Translator";
import {IonicErrorHandler} from "ionic-angular";
import {MyApp} from "../app/app.component";

export class ExceptionHandler extends IonicErrorHandler {
    constructor() {
        super()
    }

    /**
     * @internal
     */
    handleError(err: any): void {
        console.error('exception handler captchered : ', err);
        if (MyApp && MyApp.instance && MyApp.instance.rootPage) {
            let msg = MyApp.instance.alertController.create({
                title: tr('Internal Error'),
                subTitle: tr(String(err)),
                buttons: ['OK']
            });
            msg.present();
        }
        else
            IonicErrorHandler.prototype.handleError.call(this, err);
    }
}
